package cn.basic.action;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public abstract class BasicAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * @param key
	 * @param value
	 */
	public static void putSessinValue(String key,Object value){
		BasicAction.getHttpSession().setAttribute(key, value);
	}
	/**
	 * @param key
	 * @return
	 */
	public Object getSessionValueByKey(String key){
		return BasicAction.getHttpSession().getAttribute(key);
	}
	/**
	 * @param key
	 * @return
	 */
	public String getRequestValue(String key){
		return ServletActionContext.getRequest().getParameter(key);
	}
	/**
	 * @param key
	 * @param value
	 */
	public void putActionContext(String key,Object value){
		ActionContext.getContext().put(key, value);
		
	}
	
	/**
	 * @return
	 */
	public static HttpSession getHttpSession(){
		return ServletActionContext.getRequest().getSession();
	}
}
